/*
 * @Author: shiguo
 * @Date: 2023-07-20 17:58:05
 * @LastEditors: shiguo
 * @LastEditTime: 2023-07-24 16:20:07
 * @FilePath: /@aks-dev/ipush/android/src/main/java/com/sg/RNIpushModule.java
 */

package com.sg;

import android.os.Build;

import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule;
import com.facebook.react.bridge.ReactMethod;
import com.facebook.react.bridge.WritableNativeMap;

import java.util.HashMap;

public class RNIpushModule extends ReactContextBaseJavaModule {

    private final ReactApplicationContext reactContext;

    public RNIpushModule(ReactApplicationContext reactContext) {
        super(reactContext);
        this.reactContext = reactContext;
        IPushHelper.getInstance().reactContext = reactContext;
    }

    @Override
    public String getName() {
        return "RNIpush";
    }


    @ReactMethod
    public void info(final Promise promise) {
        HashMap<String, Object> map = new HashMap<>();
        IPushHelper instance = IPushHelper.getInstance();
        map.put("brand", Build.BRAND);
        map.put("token", instance.getHwToken());
        map.put("regId", instance.getXmRegId());
        WritableNativeMap info = Arguments.makeNativeMap(map);
        promise.resolve(info);
    }

}